let s:MY_CONFIG_DIR = fnamemodify($MYVIMRC, ':h') . '/config/'

" 更改后自动加载
au! BufWritePost $MYVIMRC source $MYVIMRC

function LoadMyConfig(name)
    let path = expand(s:MY_CONFIG_DIR . a:name)
    exec 'source' path
    exec 'au BufWritePost ' . path . ' source ' . path
endfunction

" 大配置
call LoadMyConfig('common.vim')
lua require('plugins')
call LoadMyConfig('maps.vim')

" 自动加载 autoload 中的配置
for v in globpath(expand(s:MY_CONFIG_DIR . 'autoload'), '*', 1, 1)
    exec 'source' v
    exec 'au BufWritePost ' . v . ' source ' . v
endfor

